package com.testing.splogin.controller;

import com.testing.splogin.dao.Result;
import com.testing.splogin.dao.UserInfo;
import com.testing.splogin.tools.MysqlUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Classname GetUserInfo
 * @Description 类型说明
 * @Date 2021/8/9 16:19
 * @Created by 特斯汀Roy
 */
@RestController
public class GetUserInfo {
    private UserInfo userInfo;
    @GetMapping("/getUserinfo")
    public Result getUserInfo(String user,String password){
        MysqlUtils my=new MysqlUtils();
        List<Map<String, String>> maps = my.querySql("select * from userinfo where username='" + user + "' and `password`='" + password + "';");
        if(maps.size()==0){
            return  new Result("-1","查询失败");
        }
        Map<String, String> firstUserinfo = maps.get(0);
        userInfo=new UserInfo();
        userInfo.setUsername(firstUserinfo.get("username"));
        userInfo.setMsg("查询成功");
        userInfo.setNickname(firstUserinfo.get("nickname"));
        userInfo.setStatusCode("200");
        userInfo.setDecription(firstUserinfo.get("describe"));
        return userInfo;

    }



}
